

//规则条件列表js代码块
var riskDictionaryPage = {
		
		//初始化一些东西
		init : function(){
			
			//比如获取下拉列表的枚举
			
		},
		
		 /*创建分页实例current*/
	    pagingTooler : new PagingTooler({
	        callbackMethodName : "riskDictionaryPage.getRiskDictionaryList",
	        pageSize : 10,
	        firstPageBtnID : "firstPageBtn",
	        lastPageBtnID : "lastPageBtn",
	        pageCodeLayerID : "pageCodeLayer",
	        recordListLayerID : "dataListLayer",
	        showCurrentPageLayerID : "currentPageLayer",
	        showRecordCountLayerID : "recordCountLayer",
	        showPageCountLayerID : "pageCountLayer",
	        showLoadingLayerID : "loadingLayer",
	        showNoRecordLayerID : "recordLayer",
	        pagingToolbarLayerID : "pagingToolbarLayer",
	        pageSizeSelectLayerID : "pageSizeSelectLayer",
	        jumpPageCodeInputID : "pageInput",
	        jumpPageBtnID : "goPageBtn",
	        pageSizeArray : [10,15,20],
	        hideColumnLayerID : "hideColumnLayer",   //隐藏列div的ID
	    }),
	    
	    search : function(){
	    	var forms = $(".parameter");
			var params = {};
			for(var i = 0 ; i < forms.length; i ++){
				var form = $(forms[i]);
				var id = form.attr("id");
				params[id] = $.trim(form.val());
			}
			
			this.pagingTooler.search(params);
			
	    },
	    
	    getRiskDictionaryList : function(){
	    	
	    	var params = this.pagingTooler.getPagingAndSearchParams();
	    	
	    	//正式的写法
	  //   	$.ajax({
			// 	url : '/riskControlWeb/riskDictionary/getRiskDictionaryList',
			// 	type :'POST',
			// 	data : params,
			// 	dataType : "json",
			// 	contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
			// 	success:function(data){
			// 		var count = data.totalCount;
			// 		var dataList = data.module;
			// 		var txt = "";
			// 		riskDictionaryPage.dataList = dataList;
			// 		for(var i = 0 ; dataList != null && i < dataList.length ; i ++){
			// 			txt +=riskDictionaryPage.createRecordTxt(dataList[i], i)
			// 		}
			// 		riskDictionaryPage.pagingTooler.showInPage(count, txt,"currentNumberPage");
			// 	}		
			// });

			//================================测试的写法========================================

			//模拟数据
			var data = {};
			data.totalCount = 20;
			data.module = [];

			
			for(var i = 0 ; i < this.pagingTooler.pageSize ; i ++){
				var item = {};
				item.dictionaryName = "名称" + i;
				item.dictionaryNo = "CCC" + i;
				item.type = "信用系统参数";
				item.memo = "德玛西亚";
				item.id = i + 1;
				data.module.push(item);
			}


			var count = data.totalCount;
			var dataList = data.module;
			var txt = "";
			riskDictionaryPage.dataList = dataList;
			for(var i = 0 ; dataList != null && i < dataList.length ; i ++){
				txt +=riskDictionaryPage.createRecordTxt(dataList[i], i)
			}
			riskDictionaryPage.pagingTooler.showInPage(count, txt,"currentNumberPage");

	    },
	    
	    //创建表格中每一条记录的文本
	    createRecordTxt : function(data , index){
	    	
	    	var txt = "";
	    	
	    	txt = '<tr>'+
	    				'<td>'+CommonUtil.fillBlank(data.dictionaryName)+'</td>'+
	    				'<td>'+CommonUtil.fillBlank(data.dictionaryNo)+'</td>'+
	    				'<td>'+CommonUtil.fillBlank(data.type)+'</td>'+
	    				'<td>'+CommonUtil.fillBlank(data.memo)+'</td>'+
	    				'<td>'+
	    					'<button onclick="redirectIframe(&quot;http://www.baidu.com&quot;)"  class="btn btn-mini">iframe跳转</button>&nbsp;'+
	    					'<button onclick="redirectTab(&quot;http://www.baidu.com&quot;)"  class="btn btn-mini">新窗口跳转</button>&nbsp;'+
	    					'<button onclick="riskDictionaryPage.popWindow();"  class="btn btn-mini">弹窗</button>'+
    					'</td>'+
    						
	    			  '</tr>';
	    	return txt;
	    },
	    
	    getDictionaryTypeTxt : function(){
	    	if(this.dictionaryTypeTxt) return this.dictionaryTypeTxt;
	    	var txt = "";
	    	var list = getEnumInfoByName("RiskDictionaryTypeEnum");
	    	for(var i = 0 ; i < list.length; i++){
	    		var item = list[i];
	    		txt+='<option value="'+item.serialNumber+'"  prefix="'+item.prefix+'">'+item.typeName+'</option>';
	    	}
	    	this.dictionaryTypeTxt = txt;
	    	return txt;
	    },

	    popWindow : function(){
	    	$('#testWindow').modal();
	    }
}

$(function(){
	
	//初始化
	riskDictionaryPage.init();
	
	//初始化表格
	riskDictionaryPage.pagingTooler.initTableList();
	
});
